#'###########################################
#'                                          #
#'  ------------------------------------    #
#'  |     COIN     __                  |    #
#'  |            >(' )                 |    #
#'  |              )/                  |    #
#'  |             /  `----/            |    #
#'  |             \  ~=- /             |    #
#'  |   ~^~^~^~^~^~^~^~^~^~^~^~^~^~^   |    #
#'  ------------------------------------    #
#'                                          #
#'###########################################

rm(list=ls())
rm(.Random.seed)

#'#
#'# Chemins de travail
#'#
R_ROOT <- "C:/UQAR/Recherche/Maitrise/Donnees"
R_WORKING_DIRECTORY <- file.path(R_ROOT, "R")
R_DATA_PATH <- file.path(R_ROOT, "Donnees")
R_RESULTS_PATH <- file.path(R_ROOT, "Resultats")

R_STATIC_DIR <- file.path(R_DATA_PATH, "Bylot/Fixe")
R_MOBILE_DIR <- file.path(R_DATA_PATH, "Bylot/Mobile")


#'#
#'# Chargement des dependances
#'# 

source(file.path(R_WORKING_DIRECTORY, "Utils/loadDependencies.R"))

DATA_PATH <- file.path(R_RESULTS_PATH, "HRCompare/v5")

statsCols <- c("sizeRatio", "overlapIndex", "propInRef", "comparedArea", "refArea")

#'#
#'# Simulations
#'# Compilation a partir des fichiers bruts et sauvegarde
#'# (Compilation des fichiers bruts via la fonction (loadSimulationFiles dans loadData.R) 
#'# 


hrStatsRaw <- data.table(cbind(read.csv(file.path(DATA_PATH, "HR_compare_raw.csv")), type="Raw", stringsAsFactors=FALSE))


dat <- hrStatsRaw[method=="kernel" & percent == 95]
dat[, deployment := as.factor(deployment)]



meanICl2(dat, var=sizeRatio, byG2="deployment")

t1 <- fread(file.path(DATA_PATH, "HR_compare_tracksGenStaticLC32_50.csv"))
t1[, iteration := 1]
t1[, type := "TrStat"]
t2 <- fread(file.path(DATA_PATH, "HR_compare_tracksGenStaticLC32_51.csv"))
t2[, iteration := 2]
t2[, type := "TrStat"]
test <-  rbindlist(list(t1,t2))
test[, deployment := as.factor(deployment)]
test[, iteration := as.factor(iteration)]


dat <- test[method=="kernel" & percent == 95]



meanICl3(dat, var=sizeRatio, byG3="iteration", byG2="deployment")
